package kr.hikt.androidcomplete01;

import kr.hikt.androidcomplete01.ch04.Ch04Main;
import kr.hikt.androidcomplete01.ch05.Ch05Main;
import kr.hikt.androidcomplete01.ch06.Ch06Main;
import kr.hikt.androidcomplete01.ch07.Ch07Main;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends ListActivity {
	private String[] lists;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		lists = getResources().getStringArray(R.array.main_list)	;
	
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lists);
		setListAdapter(adapter);
		
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Intent intent = null;
		switch(position){
		case 0:
			intent = new Intent(this, Ch04Main.class);
			break;
		case 1:
			intent = new Intent(this, Ch05Main.class);
			break;
		case 2:
			intent = new Intent(this, Ch06Main.class);
			break;
		case 3:
			intent = new Intent(this, Ch07Main.class);
			break;
		}
		startActivity(intent);
	}

}
